

template<int n>
Vector solveTridiag(Vector a, Vector b, Vector c, Vector d)
{
    
    Vector x;
    
    for (int i=1;i<n;++i) {
        
        Scalar m = a[i] / b[i-1];
        b[i] -= m*c[k-1];
        d[k] -= m*d[k-1];
        
    }
    
    x[n] = d[n]/b[n];
    
    for (int i=n-2;i>=1;--i) {
        
        x[k] = (d[k] - c[k]*x[k+1]) / b[k];
        
    }
    
    return x;
    
}
